<template>
    <div class="wrap">
        <div class="container">
            <!-- 面包屑 -->
            <div class="products_block ">
                <div class="nav_position">
                    <span class="icon_home"></span>您的位置：
                    <div class="position_detail">
                        <a href="">首页</a><span>></span>
                        <span>相关资讯</span>
                    </div>
                </div>
            </div>
            <!-- 面包屑结束 -->
            <!-- 详情开始  -->
            <div class="info_content">
                <div class="content_detail">
                    <div class="content_title">{{ model.title }}</div>
                    <div class="info_content_desc">
                        <div>
                            <span>阅读量：</span>
                            <span>{{ model.views }}</span></div>
                        <div>
                            <span>发布时间：</span>
                            <span>{{ model.time }}</span>
                        </div>
                    </div>
                    <!-- 内容部分 -->
                    <div v-html="model.content" class="content_html">
                       
                    </div>
                    <!-- 内容部分结束 -->
                </div>

                <!-- 上下翻页 -->
                <div class="bottom_operate">
                    <div class="prev_next_title">
                        <div>上一篇：<a @click="GoHandler(next)" style="cursor:pointer;">{{ next.title != null?next.title:'无' }}</a></div>
                        <div>下一篇：<a @click="GoHandler(prev)" style="cursor:pointer;">{{ prev.title != null?prev.title:'无' }}</a></div>
                    </div>
                    <nuxt-link :to="'/news/list'"  class="return_lists">返回列表</nuxt-link>

                    <!-- <nuxt-link :to="'/news/' + item.id"></nuxt-link> -->
                </div>
                <!-- 上下翻页结束 -->
            </div>
            <!-- 详情结束 -->
        </div>
    </div>
</template>

<script>
import api from "@/api/news"
export default {
    name: "New-Show",
    validate({ params }) {
        // 必须是number类型
        return /^\d+$/.test(params.show)
    },
    data() {
        return {
           model:{},
           next:{},
           prev:{},
           id: 0
        }
    },
    created(){
        console.log("id:",this.$route.params.show);
        //this.key = this.$route.query.id;
        this.doLoadData();
    },
    methods:{

        //初始化
        doLoadData(){
            let _this = this;
            let input = {
                id:_this.$route.params.show
            }
            api.GetByID(input)
            .then(res => {
                _this.model = res.data.archivesInfo        
                _this.next = res.data.next
                _this.prev =res.data.prev
            });
        },
        // 跳转页面
        GoHandler:function(item){
            // 跳转页面 判断url是否拥有外部链接若有直接跳转外链
            if(item.id != 0){
                this.$router.replace({
                    path: `/news/${item.id}`,
                })
            }
            return false
        }
    }
};
</script>
